package br.urca.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.urca.dao.DisciplinasCursadasDAO;
import br.urca.interceptor.InterceptResource;
import br.urca.model.DisciplinaCursada;

@Controller
@InterceptResource
public class DisciplinasCursadasController {

	private DisciplinasCursadasDAO mDAO;
	private Result result;
	
	public DisciplinasCursadasController() { }
	
	@Inject
	public DisciplinasCursadasController(DisciplinasCursadasDAO mDAO, Result result) {
		this.mDAO = mDAO;
		this.result = result;
	}
	
	public List<DisciplinaCursada> lista() {
		return this.mDAO.todos();
	}
	
	/*@Get("disciplinasCursadas/historico/{matricula}")
	public void historico(String matricula) {
		if (matricula != null) {
			
			Properties properties = new Properties();
			String mMatricula = null;
			
			try {
				//pega somente os números da matrícula
				properties.load(new StringReader(matricula));
				mMatricula = properties.getProperty("matricula");
				
				
			} catch (IOException e) {
				e.printStackTrace();
			}
			
			if (mMatricula != null) {
				List<DisciplinaCursada> mList = this.mDAO.buscarPorMatricula(mMatricula);
				if (mList != null) {
					this.result.use(Results.json()).from(mList, "historico").recursive().serialize();
				} else {
					this.result.use(Results.json()).from("", "historico").serialize();
				}
			}
		}
	}*/
	
}
